package com.ssm.dao;

import com.ssm.domain.Member;
import com.ssm.domain.Orders;
import com.ssm.domain.Product;
import com.ssm.domain.Traveller;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface OrdersDao {




    @Select("select * from orders")
    @Results({@Result(id = true, column = "id", property = "id"),
            @Result(column = "orderNum", property = "orderNum"), @Result(column = "orderTime", property = "orderTime"), @Result(column = "orderStatus", property = "orderStatus"), @Result(column = "peopleCount", property = "peopleCount"), @Result(column = "payType", property = "payType"), @Result(column = "orderDesc", property = "orderDesc"),
            @Result(column = "productId", property = "product", one = @One(select = "com.ssm.dao.IProductDao.findById"))})
    List<Orders> findAll() ;


    @Select("select * from orders where id = #{id}")
    @Results({@Result(id = true, column = "id", property = "id"),
            @Result(column = "orderNum", property = "orderNum"), @Result(column = "orderTime", property = "orderTime"), @Result(column = "orderStatus", property = "orderStatus"), @Result(column = "peopleCount", property = "peopleCount"), @Result(column = "payType", property = "payType"), @Result(column = "orderDesc", property = "orderDesc"),
            @Result(column = "productId", property = "product", one = @One(select = "com.ssm.dao.IProductDao.findById"))
            ,@Result(property = "member",column = "memberId",javaType = Member.class,one = @One(select = "com.ssm.dao.IMemberDao.findById"))
            ,@Result(property = "travellers",column = "id" ,javaType = List.class,many = @Many(select = "com.ssm.dao.ITraveller.findByOrdersId"))
    })
    Orders findById(String id);
}
